<style type="text/css">
    span{ color: red;}
</style>   
<div style="margin: 0 auto;width: 98%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#006600;">Edit Sale Material</div><br/>
<div style="margin: 0 auto;width:60%;height: auto;border: 1px #ccc solid; padding:20px 15px 20px 15px;-moz-border-radius:10px;">
    <div style="float: right; border: 0px #ccc solid;"><?php echo anchor('sale_management/sale_material', img('images/user_images/cancel.png')); ?></div>
    <?php echo form_open('sale_management/edit_material/' . $this->uri->segment(3)); ?>
    <?php
    echo '<table border="0" align="center" style="font-weight: lighter;font-size: 14px;">';

    //------------this is looping for selecting data----------------

    foreach ($value_material->result() as $rows_mat) {
        echo '<tr>';
        echo '<td>Customer Name<span>*</span></td>';
        echo '<td>';
        echo '<select name="customer_name">';
        echo '<option  value="0">--select--</option>';

        //-----------this is select from table student--------------------

        $get_material = $this->db->query('SELECT *FROM tbl_student');
        if ($get_material->num_rows() > 0) {
            foreach ($get_material->result() as $rows) {
                $sel_n = ($rows->stu_id == $rows_mat->stu_id) ? ' selected="selected"' : ' ';
                echo '<option value="' . $rows->stu_id . '" ' . $sel_n . '>' . $rows->stu_name . '</option>';
            }
        }
        echo '</select>';
        echo '</td>';
        echo '</tr>';

        echo '<tr>';
        echo '<td>Product Name<span>*</span></td>';
        echo '<td>';
        echo '<select name="txt_proname">';
        echo '<option  value="0">--select--</option>';

        //--------this is select from table product--------------------

        $get_material = $this->db->query('SELECT *FROM tbl_product');
        foreach ($get_material->result() as $row) {
            $sel_pro = ($row->pro_id == $rows_mat->pro_id) ? ' selected="selected"' : ' ';
            echo '<option value="' . $row->pro_id . '"' . $sel_pro . '>' . $row->pro_name . '</option>';
        }
        echo '</select>';
        echo '</td>';
        echo '</tr>';

        echo '<tr>';
        echo '<td>Sale Quantity<span>*</span></td>';
        echo '<td>' . form_input('txt_qauntity', $rows_mat->sal_quantity) . '</td>';
        echo '</tr>';

        echo '<tr>';
        echo '<td>Sale Date<span>*</span></td>';
        ?>
        <td>: <input type="text" name="txt_saleDate" class="datepicker"  value="<?php echo $rows_mat->sal_date ?>" /><?php echo form_error('txt_saleDate'); ?></td> 
        <?php
        echo '</tr>';

        echo '<tr>';
        echo '<td>Price<span>*</span></td>';
        echo '<td>';
        echo '<select name="txt_price">';
        echo '<option  value="" disable="disable">--select--</option>';

        //---------this is select data from table product------------------

        $get_material = $this->db->query('SELECT *FROM tbl_product');
        if ($get_material->num_rows() > 0) {

            foreach ($get_material->result() as $rows) {
                $sel_price = ($rows->pro_id == $rows_mat->pro_id) ? ' selected="selected"' : ' ';
                echo '<option value="' . $rows->pro_price . '"' . $sel_price . '>' . $rows->pro_name . ' &nbsp;|&nbsp; $' . $rows->pro_price . '</option>';
            }
        }
        echo '</select>';
        echo '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Descripton</td>';
        echo '<td> ' . form_textarea(array('name' => 'txt_descriptionn', 'rows' => '8', 'cols' => '50', 'value' => $rows_mat->sal_description)) . '</td>';
        echo'</tr>';

        echo '<tr>';
        echo '<td></td>';
        echo '<td>' . form_input(array('name' => 'btn_submit', 'type' => 'submit', 'value' => 'Submit')) . form_input(array('type' => 'reset', 'value' => 'Reset')) . '</td>';
        //echo '<td>'.anchor(array('type'=>'button','students/manager'=>'Cansel')).'</td>';
        echo '</tr>';
    }
    echo '</table>';
    ?>
        <?php echo form_close(); ?>
</div>